/**
 * Copyright &copy; 2013-2015 山东易科德软件有限公司   All rights reserved.
 */
package cn.net.ecode.modules.file.entity;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.validator.constraints.Length;

import cn.net.ecode.common.persistence.DataEntity;
import cn.net.ecode.common.persistence.annotation.Id;
import cn.net.ecode.common.web.Servlets;

/**
 * 文件用户业务管理Entity
 * @author jiangwenchao
 * @version 2015-03-18
 */
public class FileUserBiz extends DataEntity<FileUserBiz> {
	
	private static final long serialVersionUID = 1L;
	private String fileUserBizId;		// 用户业务ID
	private FileUser fileUser;
	private String bizCategory;		// 业务类型
	private String bizKey;		// 业务主键

	private String fileUserIds; // 当前上传文件的ID串，多个逗号隔开
	
	public FileUserBiz() {
		super();
	}

	public FileUserBiz(String fileUserBizId){
		super();
		this.fileUserBizId = fileUserBizId;
	}

	public FileUserBiz(FileUser fileUser) {
		super();
		this.fileUser = fileUser;
	}

	public FileUserBiz(String bizCategory, String bizKey) {
		super();
		this.bizCategory = bizCategory;
		this.bizKey = bizKey;
		// 根据分类获取文件用户ID串
		HttpServletRequest request = Servlets.getRequest();
		if (request != null){
			this.fileUserIds = Servlets.getRequest().getParameter(bizCategory);
		}
	}
	
	public FileUserBiz(String bizCategory, DataEntity<?> bizObj) {
		this(bizCategory, bizObj.getId());
	}
	
	@Id
	public String getFileUserBizId() {
		return fileUserBizId;
	}

	public void setFileUserBizId(String fileUserBizId) {
		this.fileUserBizId = fileUserBizId;
	}
	
	
	@Length(min=0, max=32, message="业务类型长度不能大于 32 个字符")
	public String getBizCategory() {
		return bizCategory;
	}

	public void setBizCategory(String bizCategory) {
		this.bizCategory = bizCategory;
	}
	
	@Length(min=0, max=64, message="业务主键长度不能大于 64 个字符")
	public String getBizKey() {
		return bizKey;
	}

	public void setBizKey(String bizKey) {
		this.bizKey = bizKey;
	}

	public FileUser getFileUser() {
		return fileUser;
	}

	public void setFileUser(FileUser fileUser) {
		this.fileUser = fileUser;
	}

	public String getFileUserIds() {
		return fileUserIds;
	}

	public void setFileUserIds(String fileUserIds) {
		this.fileUserIds = fileUserIds;
	}
	
}